package simple.demo.springintegration.demo.chapter5.component;

import javax.jms.ConnectionFactory;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.jms.connection.CachingConnectionFactory;
import org.springframework.stereotype.Component;

@Component
public class JmsConfiguration {

	@Bean(name="connectionFactory")
	public ConnectionFactory getConnectionFactory() {
		ActiveMQConnectionFactory connFactory = 
				new ActiveMQConnectionFactory("vm://localhost");
		
		CachingConnectionFactory cachingConnFactory =
				new CachingConnectionFactory(connFactory);
		cachingConnFactory.setSessionCacheSize(10);
		cachingConnFactory.setCacheProducers(false);
		
		return cachingConnFactory;
	}
}
